//
//  P_P_Equatable_DemoVC.swift
//  APSwift
//
//  Created by jianbo.pei on 2022/6/5.
//

import UIKit

class P_P_Equatable_DemoVC: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        test1()
        test2()
    }
    
    private func test1() {
        let zs = PPEStudent(name: "张三", id: "001")
        let ls = PPEStudent(name: "李四", id: "002")
        print("zs和ls是否是同一个人？：：：： \(zs == ls)")
    }
    
    private func test2() {
        let zs = PPEPerson()
        zs.name = "张三"
        zs.gender = 0
        
        let ls = PPEPerson()
        ls.name = "李四"
        ls.gender = 0
        
        print("根据名字是否相等判断zs和ls是否是同一个人：：：：\(zs == ls)")
    }

}


struct PPEStudent: Equatable {
    var name: String
    var id: String
}


class PPEPerson: Equatable {
    static func == (lhs: PPEPerson, rhs: PPEPerson) -> Bool {
        return lhs.name == rhs.name
    }
    
    var name: String = ""
    var gender: Int = 0
}
